import Vue from 'vue'
/** 引入css文件 */
import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import './assets/iconfont/iconfont.css'// 引入iconfont
// import '//at.alicdn.com/t/font_2189661_83pc2p0pb45.css'// 引入银行
/** 引入js文件 */
// import '//at.alicdn.com/t/font_2189661_smwpksbr7k.js'// 银行图标
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
import VueClipboard from 'vue-clipboard2'
import '@/utils/extend'// 日期格式转换
import '@/styles/index.scss' // global css s
import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control
// 拷的流程设计器的代码
import 'babel-polyfill'

import './plugins/axios'

import './plugins/element.js'
// import '@/styles/override-element-ui.css'
import func from './plugins/preload.js'
import ydc from './plugins/common.js'
import nodeWrap from '@/components/flowset/nodeWrap'
Vue.use(nodeWrap)
Vue.component('nodeWrap', nodeWrap) // 初始化组件
import addNode from '@/components/flowset/addNode'
Vue.use(addNode)
Vue.component('addNode', addNode) // 初始化组件

import animated from 'animate.css'
Vue.use(animated)
import wow from 'wowjs'
Vue.prototype.$wow = wow
Vue.prototype.$func = func
Vue.prototype.$ydc = ydc
Vue.config.productionTip = false
Vue.directive('enterNumber', {
  bind: function(el, { value = 2 }) {
    el = el.nodeName === 'INPUT' ? el : el.children[0]
    var RegStr = value === 0 ? `^[\\+\\-]?\\d+\\d{0,0}` : `^[\\+\\-]?\\d+\\.?\\d{0,${value}}`
    el.addEventListener('keyup', function() {
      el.value = el.value.match(new RegExp(RegStr, 'g'))
      el.dispatchEvent(new Event('input'))
    })
  }
})

Vue.directive('focus', {
  // 当被绑定的元素插入到 DOM 中时……
  inserted: function(el) {
    el.focus()
  }
})

// 流程设计器代码结束

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}

// set ElementUI lang to EN
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

Vue.use(VueClipboard)
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
